package com.cucn.staservice.schedule;

import com.cucn.staservice.service.StatisticsDailyService;
import com.cucn.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 定时任务类
 *
 * @author KouChaoJie
 * @since: 2021/10/15 14:53
 */
@Component
public class ScheduledTask {
    @Autowired
    private StatisticsDailyService staService;

    /**
     * 在每天凌晨一点,执行方法把前一天数据查询进行添加
     */
    @Scheduled(cron = "0 0 1 * * ? ")
    public void task() {
        staService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }
}
